#pragma once
#include "InternalsPlugin.hpp"
#include "Sprite.hpp"
#include "DriverInfo.hpp"
#include "TimingInfo.hpp"
#include "TypeDefs.hpp"

class WidgetTower
{
public:
	WidgetTower(const char *pRootPath, const char *pIniUIFilename, const char *pIniDriverMappingFilename, const char *pIniVehiculeClassMappingFilename);
	~WidgetTower(void);

	std::string getTimeAsString(double seconds, bool forceAllFields, bool padHighest, bool showMillis, bool showFullMillis);
	

	void init(const ScreenInfoV01 &info, float ratio, float ratioWidth, float ratioHeight, Sprite spriteList[]);
	void updateData(const ScoringInfoV01 &info, DriverInfo orderedDriverInfos[]);
	void render(int profileIndex, const ScreenInfoV01 &info, bool isRace, const LPD3DXFONT *fontList, const D3DCOLOR *colorList, Sprite spriteList[], DriverInfo orderedDriverInfos[], TimingInfoPerCategoryMap & timingInfoPerCategoryMap, int activeCategoryIndex); 

	bool initialized;
	const char *rootPath;
	char iniUIFilename[800];
	const char *iniDriverMappingFilename;
	const char *iniVehiculeClassMappingFilename;

	char mLastDriverName[32]; // track if we change the viewed driver (between to updateData call)

	int nbProfiles;
	PluginProfile profiles[10];

	RECT tmpRect;

	char tmp[1000];

	int nbDrivers;
	// Driver Timing (general)
	bool available;
	ImageData bgImageData;
	int nextLineOffsetY;
	int maxNbDriverDisplayed;
	int towerMode;
  // Line background
  bool lineBgAvailable;
  ImageData lineBgImageData;

  // place text
  bool placeAvailable;
  ImageData placeImageData;
  TextData placeTextData;

  // first place specificities
  bool firstPlaceAvailable;
  ImageData firstPlaceImageData;
  TextData firstPlaceTextData;
  // first place specificities (ina category)
  bool firstPlaceInCatAvailable;
  ImageData firstPlaceInCatImageData;
  TextData firstPlaceInCatTextData;

  // driver name;
  bool driverNameAvailable;
  TextData driverNameTextData;

  // category
  bool categoryAvailable;
  ImageData categoryImageData;
  TextData categoryTextData;
  int categoryOriginalImageColorIndex;
  int categoryOriginalTextColorIndex;

  // Number
  bool numberAvailable;
  TextData numberTextData;
  int autoSizeGap;

  // data;
  bool dataAvailable;
  ImageData dataImageData;
  TextData dataTextData;
};

